<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

class UserCollection extends Model
{
    use HasDateTimeFormatter;
    // use SoftDeletes;
    // const CREATED_AT = 'create_time';
    // const UPDATED_AT = 'update_time';

    // public $timestamps = true;

    protected $table = 'eb_user_collection';

    protected $fillable = [
        'id',
        'user_id',
        'info_id',
        'create_time',
        'update_time',
        'delete_time',
        'type',
        'status'
    ];

    /**
     * 根据用户id和类型返回关注id
     *
     * @Author hechengwei
     * @email chichiooo@sina.com
     * @DateTime 2022-03-09
     * @param array $where
     * @return mixed
     */
    public static function getMemberListById($where = [])
    {
        $where = function ($query) use ($where) {

            $query->where('status', 1);
            $query->where('user_id', $where['user_id']);
            $query->where('type', $where['type']);
        };

        return self::where($where)->get()->pluck('info_id')->toArray();
    }
}
